/**
 ******************************************************************************
 * @file    disp.c
 * @author  测试1组（houtiezhu）
 * @version v0
 * @date    09-07-2019
 *
 * @verbatim
 **/
/* Includes ------------------------------------------------------------------*/

#include "define.h"
#include "disp.h"
#include "power.h"
#include "clk.h"
#include "gpio.h"
#include "time.h"
#include "uart.h"
#include "spk.h"
#include "flash.h"
#include "adc.h"
#include "algo.h"
#include "bp.h"
#include "func.h"
#include "op.h"
#include "pwm.h"
#include "voice.h"
#include "queue.h"
#include "inner_voice.h"

uint32 LcdBuf[11];

/*
const uint8  U80EHLCD[] =
{0xAF,0x06,0x6D,0x4F,0xC6,0xCB,0xEB,0x0E,0xEF,0xCF,0xEE,0x60,0xA9,0x67,0xE9,0xE8,0x00,0xE6,0x02,0xA1,0x63,0x02,0x62,0x40,0xA7,0xE3,0xE1,0xEC,0xAE};
//	 0	 1	  2	  3	   4	  5	  6	   7	  8	   9   A-a  r-b  C-c d-d   E-e	F-f	 -10 H-11 I-12 L-13	o-14 i-15 n-16 --17	U-18  B-19 t-1a	p-1b	N-1c
*/


const uint8 LCDTableA[]=
{
		AChar_0,                    // char "0"  0x00
		AChar_1,                    // char "1"  0x01
		AChar_2,                    // char "2"  0x02
		AChar_3,                    // char "3"  0x03
		AChar_4,                    // char "4"  0x04
		AChar_5,                    // char "5"  0x05
		AChar_6,                    // char "6"  0x06
		AChar_7,                    // char "7"  0x07
		AChar_8,                    // char "8"  0x08
		AChar_9,                    // char "9"  0x09
		AChar_A,                    // char "A"  0x0a
		AChar_R,						//B
       //  AChar_B,                    // char "b"  0x0b
		AChar_C,                    // char "C"  0x0c
		AChar_D,                    // char "d"  0x0d
		AChar_E,                    // char "E"  0x0e
		AChar_F,                    // char "F"  0x0f
		AChar_NULL,				//10
		AChar_H,					//11
		AChar_I,					//12
		AChar_L,					//13
		AChar_O,					//14
		AChar_i,					//15
		AChar_n,					//16
		AChar_G,					//17
		AChar_U,					//18
		AChar_B,                    // char "b"  0x0b
		AChar_T,					//16
		AChar_P,					//14
		AChar_N
};
const uint8 LCDTableB[]=
{
		BChar_0,                    // char "0"  0x00
		BChar_1,                    // char "1"  0x01
		BChar_2,                    // char "2"  0x02
		BChar_3,                    // char "3"  0x03
		BChar_4,                    // char "4"  0x04
		BChar_5,                    // char "5"  0x05
		BChar_6,                    // char "6"  0x06
		BChar_7,                    // char "7"  0x07
		BChar_8,                    // char "8"  0x08
		BChar_9,                    // char "9"  0x09
		BChar_A,                    // char "A"  0x0a
		BChar_R,						//B
		BChar_C,                    // char "C"  0x0c
		BChar_D,                    // char "d"  0x0d
		BChar_E,                    // char "E"  0x0e
		BChar_F,                    // char "F"  0x0f
		BChar_NULL,				//18
		BChar_H,					//10
		BChar_I,					//11
		BChar_L,					//12
		BChar_O,					//13
		BChar_i,					//11
		BChar_n,					//11
		BChar_G,					//11
		BChar_U,					//16
		BChar_B,                    // char "b"  0x0b
		BChar_T,					//16
		BChar_P,					//14
		BChar_N
};


const uint8 LCDTableC[]=
{
		CChar_0,                    // char "0"  0x00
		CChar_1,                    // char "1"  0x01
		CChar_2,                    // char "2"  0x02
		CChar_3,                    // char "3"  0x03
		CChar_4,                    // char "4"  0x04
		CChar_5,                    // char "5"  0x05
		CChar_6,                    // char "6"  0x06
		CChar_7,                    // char "7"  0x07
		CChar_8,                    // char "8"  0x08
		CChar_9,                    // char "9"  0x09
		CChar_A,                    // char "A"  0x0a
		CChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		CChar_C,                    // char "C"  0x0c
		CChar_D,                    // char "d"  0x0d
		CChar_E,                    // char "E"  0x0e
		CChar_F,                    // char "F"  0x0f
		CChar_NULL,				//18
		CChar_H,					//10
		CChar_I,					//11
		CChar_L,					//12
		CChar_O,					//13
		CChar_i,					//11
		CChar_n,					//11
		CChar_G,					//11
		CChar_U,					//16
		CChar_B,                    // char "b"  0x0b
		CChar_T,					//16
		CChar_P,					//14
		CChar_N
};


const uint8 LCDTableD[]=
{
		DChar_0,                    // char "0"  0x00
		DChar_1,                    // char "1"  0x01
		DChar_2,                    // char "2"  0x02
		DChar_3,                    // char "3"  0x03
		DChar_4,                    // char "4"  0x04
		DChar_5,                    // char "5"  0x05
		DChar_6,                    // char "6"  0x06
		DChar_7,                    // char "7"  0x07
		DChar_8,                    // char "8"  0x08
		DChar_9,                    // char "9"  0x09
		DChar_A,                    // char "A"  0x0a
		DChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		DChar_C,                    // char "C"  0x0c
		DChar_D,                    // char "d"  0x0d
		DChar_E,                    // char "E"  0x0e
		DChar_F,                    // char "F"  0x0f
		DChar_NULL,				//18
		DChar_H,					//10
		DChar_I,					//11
		DChar_L,					//12
		DChar_O,					//13
		DChar_i,					//11
		DChar_n,					//11
		DChar_G,					//11
		DChar_U,					//16
		DChar_B,                    // char "b"  0x0b
		DChar_T,					//16
		DChar_P,					//14
		DChar_N
};


const uint8 LCDTableE[]=
{
		EChar_0,                    // char "0"  0x00
		EChar_1,                    // char "1"  0x01
		EChar_2,                    // char "2"  0x02
		EChar_3,                    // char "3"  0x03
		EChar_4,                    // char "4"  0x04
		EChar_5,                    // char "5"  0x05
		EChar_6,                    // char "6"  0x06
		EChar_7,                    // char "7"  0x07
		EChar_8,                    // char "8"  0x08
		EChar_9,                    // char "9"  0x09
		EChar_A,                    // char "A"  0x0a
		EChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		EChar_C,                    // char "C"  0x0c
		EChar_D,                    // char "d"  0x0d
		EChar_E,                    // char "E"  0x0e
		EChar_F,                    // char "F"  0x0f
		EChar_NULL,				//18
		EChar_H,					//10
		EChar_I,					//11
		EChar_L,					//12
		EChar_O,					//13
		EChar_i,					//11
		EChar_n,					//11
		EChar_G,					//11
		EChar_U,					//16
		EChar_B,                    // char "b"  0x0b
		EChar_T,					//16
		EChar_P,					//14
		EChar_N
};


const uint8 LCDTableF[]=
{
		FChar_0,                    // char "0"  0x00
		FChar_1,                    // char "1"  0x01
		FChar_2,                    // char "2"  0x02
		FChar_3,                    // char "3"  0x03
		FChar_4,                    // char "4"  0x04
		FChar_5,                    // char "5"  0x05
		FChar_6,                    // char "6"  0x06
		FChar_7,                    // char "7"  0x07
		FChar_8,                    // char "8"  0x08
		FChar_9,                    // char "9"  0x09
		FChar_A,                    // char "A"  0x0a
		FChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		FChar_C,                    // char "C"  0x0c
		FChar_D,                    // char "d"  0x0d
		FChar_E,                    // char "E"  0x0e
		FChar_F,                    // char "F"  0x0f
		FChar_NULL,				//18
		FChar_H,					//10
		FChar_I,					//11
		FChar_L,					//12
		FChar_O,					//13
		FChar_i,					//11
		FChar_n,					//11
		FChar_G,					//11
		FChar_U,					//16
		FChar_B,                    // char "b"  0x0b
		FChar_T,					//16
		FChar_P,					//14
		FChar_N
};

const uint8 LCDTableG[]=
{
		GChar_0,                    // char "0"  0x00
		GChar_1,                    // char "1"  0x01
		GChar_2,                    // char "2"  0x02
		GChar_3,                    // char "3"  0x03
		GChar_4,                    // char "4"  0x04
		GChar_5,                    // char "5"  0x05
		GChar_6,                    // char "6"  0x06
		GChar_7,                    // char "7"  0x07
		GChar_8,                    // char "8"  0x08
		GChar_9,                    // char "9"  0x09
		GChar_A,                    // char "A"  0x0a
		GChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		GChar_C,                    // char "C"  0x0c
		GChar_D,                    // char "d"  0x0d
		GChar_E,                    // char "E"  0x0e
		GChar_F,                    // char "F"  0x0f
		GChar_NULL,				//18
		GChar_H,					//10
		GChar_I,					//11
		GChar_L,					//12
		GChar_O,					//13
		GChar_i,					//11
		GChar_n,					//11
		GChar_G,					//11
		GChar_U,					//16
		GChar_B,                    // char "b"  0x0b
		GChar_T,					//16
		GChar_P,					//14
		GChar_N
};

const uint8 LCDTableH[]=
{
		HChar_0,                    // char "0"  0x00
		HChar_1,                    // char "1"  0x01
		HChar_2,                    // char "2"  0x02
		HChar_3,                    // char "3"  0x03
		HChar_4,                    // char "4"  0x04
		HChar_5,                    // char "5"  0x05
		HChar_6,                    // char "6"  0x06
		HChar_7,                    // char "7"  0x07
		HChar_8,                    // char "8"  0x08
		HChar_9,                    // char "9"  0x09
		HChar_A,                    // char "A"  0x0a
		HChar_R,						//B
       //  Char_B,                    // char "b"  0x0b
		HChar_C,                    // char "C"  0x0c
		HChar_D,                    // char "d"  0x0d
		HChar_E,                    // char "E"  0x0e
		HChar_F,                    // char "F"  0x0f
		HChar_NULL,				//18
		HChar_H,					//10
		HChar_I,					//11
		HChar_L,					//12
		HChar_O,					//13
		HChar_i,					//11
		HChar_n,					//11
		HChar_G,					//11
		HChar_U,					//16
		HChar_B,                    // char "b"  0x0b
		HChar_T,					//16
		HChar_P,					//14
		HChar_N
};

static void Delayx(uint16 dey)
{
    uint16 k = dey;
    while (k--)
        ;
}

void user_LCD_StructInit(void)
{
    LCD_InitTypeDef LCD_InitStruct;
    LCD_InitStruct.BIAS = DISABLE; // 20211108  1/3 change to 1/4
    LCD_InitStruct.LCDBL = ENABLE;
    LCD_InitStruct.LCDDUTY = LCDDUTY_6COM;      // 20210713
    LCD_InitStruct.LCDCLKS = LCDCLKS_ILRC_DIV2; //
    LCD_InitStruct.LCDCLKS_DIV = LCDCLKS_DIV4;  // 20210723 64 to 32
    LCD_InitStruct.LCDWAVE = LCDWAVE_B;

    LCD_InitStruct.LCDPin_Mode_COM = 0xff;        // 6com && seg 2 3
    LCD_InitStruct.LCDPin_Mode_SEG1 = 0xfcff8000; //seg 4 ~ 31
    #if 22
    LCD_InitStruct.LCDPin_Mode_SEG2 = 0x03c;      //seg 32 ~ 43
    #else
    LCD_InitStruct.LCDPin_Mode_SEG2 = 0x03f;      //seg 32 ~ 43
    #endif
    LCD_Init(&LCD_InitStruct);
    LCD_CPRCmd(ENABLE);
    LCD_CPRCLKConfig(LCD_IHRC_DIV8);        //
    LCD_VLCDLevelConfig(LCD_VLCDLevel_3V6); // 20211108 3v6 change to 4v2
    // LCD_CPRCmd(ENABLE);
    LCD_Cmd(ENABLE);
    LCD_ClearDisALL();
}

void UserLCD_Init(void)
{
    #if 22
    return;
    #endif
    RCC_APBPeriphClockCmd(RCC_APBPeriph_LCD, ENABLE); // 外设时钟使能
    LCD_DeInit();
    user_LCD_StructInit();
    DarkAllIcon();
    Delayx(1000);
    // ShowAllIcon();
    // LCD_DisALL();
    Delayx(1000);
}

void DarkAllIcon(void)
{
	uint8 k;
	// for(k=0;k<11;k++)
	// {
	// 	LcdBuf[k] = 0;
	// }

	for(k=0;k<TOTAL_SEGMENTS_NUM;k++)
	{
		seg_buf[k] = 0x00;
	}
    lcd_ram_refresh(seg_buf);
    LCD_VLCDLevelConfig(LCD_VLCDLevel_3V6);//分显电压

}



void ShowAllIcon(void)
{
	uint8 k;
	// for(k=0;k<11;k++)
	// {
	// 	LcdBuf[k] = 0xFFFFFFFF;
	// }

	LCD_VLCDLevelConfig(LCD_VLCDLevel_3V6);//全显电压
	for(k=0;k<TOTAL_SEGMENTS_NUM;k++)
	{
		seg_buf[k] = 0xFF;
	}
    lcd_ram_refresh(seg_buf);

	// LCD->DR0 = 0xFFFFFFFF;
	// LCD->DR1 = 0xFFFFFFFF;
	// LCD->DR2 = 0xFFFFFFFF;
	// LCD->DR3 = 0xFFFFFFFF;
	// LCD->DR4 = 0xFFFFFFFF;
	// LCD->DR5 = 0xFFFFFFFF;
	// LCD->DR6 = 0xFFFFFFFF;
	// LCD->DR7 = 0xFFFFFFFF;//0x00FFFFFF
	// LCD->DR8 = 0xFFFFFFFF;
	// LCD->DR9 = 0xFFFFFFFF;
	// LCD->DR10 = 0xFFFFFFFF;
}


uint8 get_position_address(uint8 position)
{
    uint8 res = 0;
    switch (position)
    {
    case MonthSingle:
    res = 22;//
        break;
    case DayTen:
    res = 26;//
        break;
    case DaySingle:
    res = 27;//
        break;
    case SYSTen:
    res = 17;//
        break;
    case SYSHundred:
    res = 18;
        break;
    case SYSSingle:
    res = 2;
        break;

    case DIASingle:
    res = 2;//
        break;
    case DIATen:
    res = 17;
        break;
    case DIAHundred:
    res = 18;
        break;

    case PulseSingle:
    res = 35;
        break;
    case PulseTen:
    res = 32;
        break;
    case MemorySetSingle:
    res = 23;
        break;
    case MemorySetTen:
    res = 29;
        break;
    case MINSingle:
    res = 37;
        break;
    case MINTen:
    res = 33;
        break;
    case HourSingle:
    res = 32;
        break;
    default:
        break;
    }

	return res;
}

#define LCD_RAM_MAX 11
uint8_t seg_buf[TOTAL_SEGMENTS_NUM] = {0}; //seg缓存 对应43个seg引脚

//将seg缓存数据刷新到lcd显示寄存器
//seg_buf 传入要刷新的8位缓存 最大刷新43字节 对应43个seg/
void lcd_ram_refresh(uint8_t *seg_buf)
{
    volatile uint32_t *lcd_ram;
    volatile uint32_t *p_u32_temp;
    uint8_t lcd_count;

    lcd_ram = (volatile uint32_t *)&LCD->DR0;//取寄存器地址
    p_u32_temp = (volatile uint32_t *)&seg_buf[0];//取缓存地址并转成32位
    // lcd_ram_init();
    for (lcd_count = 0; lcd_count < LCD_RAM_MAX; lcd_count++)
    {
        lcd_ram[lcd_count] = p_u32_temp[lcd_count];//将缓存刷新到lcd显示寄存器
    }
}

void DisplayHalfByte(uint8 LCDData,uint8 position)
{
	uint8_t LCDByte;
	volatile uint8_t p;
//	uint8 temp_position = 0;
    p = get_position_address(position);

    switch (position)
    {
    case DIAHundred:
    	LCDByte=LCDTableH[LCDData];	//
        if ((LCDData == 0 || LCDData > 3) && LCDData != 0x10 && LCDData != 0x0e)
        {
            return;
        }
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x07);
        p++;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x38) >> 3;
        break;
    case SYSHundred:
    	LCDByte=LCDTableH[LCDData];	//
        if ((LCDData == 0 || LCDData > 3) && LCDData != 0x10 && LCDData != 0x0e)
        {
            return;
        }
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x07) << 3;
        p++;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x38);
        break;
    case MonthSingle:
    case DayTen:
    	LCDByte=LCDTableG[LCDData];	//
		seg_buf[p] &= ~(0x01 << 2 | 0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x0F)<<2;
        if (position == MonthSingle)
        {
            p--;
        }
        else
        {
            p = 23;
        }
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= ((LCDByte & 0x70) >> 1);
        break;
    case DaySingle:
    	LCDByte=LCDTableF[LCDData];	//
		seg_buf[p] &= ~(0x01 << 2 | 0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x0F)<<2;
        p++;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= ((LCDByte & 0x70) >> 1);
        break;
    case PulseTen:
    	LCDByte=LCDTableC[LCDData];	//
		seg_buf[p] &= ~(0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x03)<<1;
        p++;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= ((LCDByte & 0x1c) >> 2);
        p++;
        seg_buf[p] &= ~(0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= ((LCDByte & 0x60) >> 4);
        break;
    case DIATen:
    	LCDByte=LCDTableB[LCDData];	//
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x07);
        p--;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x38) >> 3;
        p--;
		seg_buf[p] &= ~(0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x40) >> 4;
        break;
    case DIASingle:
    	LCDByte=LCDTableA[LCDData];	//
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x07);
        p++;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x38) >> 3;
        p = 15;
		seg_buf[p] &= ~(0x01 << 1);
        seg_buf[p] |= (LCDByte & 0x40) >> 5;
        break;
    case SYSSingle:
    	LCDByte=LCDTableA[LCDData];	//
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x07) << 3;
        p++;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x38);
        p = 15;
		seg_buf[p] &= ~(0x01 << 4);
        seg_buf[p] |= (LCDByte & 0x40) >> 2;
        break;
    case SYSTen:
    	LCDByte=LCDTableB[LCDData];	//
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x07) << 3;
        p--;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x38);
        p--;
		seg_buf[p] &= ~(0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x40) >> 1;
        break;
    case HourSingle:
    	LCDByte=LCDTableE[LCDData];	//
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x07) << 3;
        p--;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x38);
        p--;
		seg_buf[p] &= ~(0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x40) >> 1;
        break;
    case MINTen:
    	LCDByte=LCDTableC[LCDData];	//
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4);
        seg_buf[p] |= (LCDByte & 0x03)<<3;
        p++;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= ((LCDByte & 0x1c) << 1);
        p++;
        seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4);
        seg_buf[p] |= ((LCDByte & 0x60) >> 2);
        break;
    case MINSingle:
    	LCDByte=LCDTableE[LCDData];	//
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x07) << 3;
        p--;
		seg_buf[p] &= ~(0x01 << 3 | 0x01 << 4 | 0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x38);
        p--;
		seg_buf[p] &= ~(0x01 << 5);
        seg_buf[p] |= (LCDByte & 0x40) >> 1;
        break;
    case MemorySetSingle:
    	LCDByte=LCDTableD[LCDData];	//
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= (LCDByte & 0x03);
        p = 26;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= ((LCDByte & 0x0c) >> 2);
        p++;
        seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= ((LCDByte & 0x30) >> 4);
        p = 31;
        seg_buf[p] &= ~(0x01 << 0);
        seg_buf[p] |= ((LCDByte & 0x40) >> 6);
        break;
    case MemorySetTen:
    	LCDByte=LCDTableD[LCDData];	//
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= (LCDByte & 0x03);
        p = 21;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= ((LCDByte & 0x0c) >> 2);
        p++;
        seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1);
        seg_buf[p] |= ((LCDByte & 0x30) >> 4);
        p = 35;
        seg_buf[p] &= ~(0x01 << 0);
        seg_buf[p] |= ((LCDByte & 0x40) >> 6);
        break;
    case PulseSingle:
    	LCDByte=LCDTableC[LCDData];	//
		seg_buf[p] &= ~(0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= (LCDByte & 0x03)<<1;
        p++;
		seg_buf[p] &= ~(0x01 << 0 | 0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= ((LCDByte & 0x1c) >> 2);
        p++;
        seg_buf[p] &= ~(0x01 << 1 | 0x01 << 2);
        seg_buf[p] |= ((LCDByte & 0x60) >> 4);
        break;
    default:
        break;
    }
    lcd_ram_refresh(seg_buf);
}



void DisplaySeg(uint8 SegData, uint8 position, uint8 LcdDR)
{
    if (position > 31)
        return;
    if (LcdDR > 10)
        return;
    if (SegData)
        SegData = (SegData & 0) | 0x01;
    LcdBuf[LcdDR] = ((LcdBuf[LcdDR] & (~(0x01 << position))) | (uint32)(SegData << position));
    if (LcdDR == 0)
        LCD->DR0 = LcdBuf[LcdDR];
    else if (LcdDR == 1)
        LCD->DR1 = LcdBuf[LcdDR];
    else if (LcdDR == 2)
        LCD->DR2 = LcdBuf[LcdDR];
    else if (LcdDR == 3)
        LCD->DR3 = LcdBuf[LcdDR];
    else if (LcdDR == 4)
        LCD->DR4 = LcdBuf[LcdDR];
    else if (LcdDR == 5)
        LCD->DR5 = LcdBuf[LcdDR];
    else if (LcdDR == 6)
        LCD->DR6 = LcdBuf[LcdDR];
    else if (LcdDR == 7)
        LCD->DR7 = LcdBuf[LcdDR];
    else if (LcdDR == 8)
        LCD->DR8 = LcdBuf[LcdDR];
    else if (LcdDR == 9)
        LCD->DR9 = LcdBuf[LcdDR];
    else if (LcdDR == 10)
        LCD->DR10 = LcdBuf[LcdDR];
}

void LCD5bitDisplay(uint16 TwoByte)
{
    uint8 Temp5;
    uint8 Temp4;
    uint8 Temp3;
    uint8 Temp2;
    uint8 Temp1;
    Temp5 = TwoByte / 10000;
    Temp4 = (TwoByte % 10000) / 1000;
    Temp3 = (TwoByte % 1000) / 100;
    Temp2 = (TwoByte % 100) / 10;
    Temp1 = TwoByte % 10;
    DisplayHalfByte(Temp5, 7);
    DisplayHalfByte(Temp4, 8);
    DisplayHalfByte(Temp3, 9);
    DisplayHalfByte(Temp2, 11);
    DisplayHalfByte(Temp1, 12);
}

void LCD5bitDisplayT(uint16 TwoByte)
{
    uint8 Temp5;
    uint8 Temp4;
    uint8 Temp3;
    uint8 Temp2;
    uint8 Temp1;
    Temp5 = TwoByte / 10000;
    Temp4 = (TwoByte % 10000) / 1000;
    Temp3 = (TwoByte % 1000) / 100;
    Temp2 = (TwoByte % 100) / 10;
    Temp1 = TwoByte % 10;
    DisplayHalfByte(Temp5, 1);
    DisplayHalfByte(Temp4, 2);
    DisplayHalfByte(Temp3, 3);
    DisplayHalfByte(Temp2, 4);
    DisplayHalfByte(Temp1, 5);
}

void LCD8bitDisplay(uint8 DDataH, uint8 DDataM, uint8 DDataL)
{
    uint32 temp9;
    uint8 Temp8;
    uint8 Temp7;
    uint8 Temp6;
    uint8 Temp5;
    uint8 Temp4;
    uint8 Temp3;
    uint8 Temp2;
    uint8 Temp1;

    temp9 = DDataH * 0x10000 + DDataM * 0x100 + DDataL;
    Temp8 = temp9 / 10000000;
    Temp7 = (temp9 % 10000000) / 1000000;
    Temp6 = (temp9 % 1000000) / 100000;
    Temp5 = (temp9 % 100000) / 10000;
    Temp4 = (temp9 % 10000) / 1000;
    Temp3 = (temp9 % 1000) / 100;
    Temp2 = (temp9 % 100) / 10;
    Temp1 = temp9 % 10;

    DisplayHalfByte(Temp8, 8);
    DisplayHalfByte(Temp7, 7);
    DisplayHalfByte(Temp6, 5);
    DisplayHalfByte(Temp5, 4);
    DisplayHalfByte(Temp4, 11);
    DisplayHalfByte(Temp3, 10);
    DisplayHalfByte(Temp2, 2);
    DisplayHalfByte(Temp1, 1);
}

//******************************************************************************
// DisplayToPUL
//******************************************************************************
void DisplayToPUL(unsigned char i)
{
    unsigned char j;
    unsigned char ii;
    ii = i;

    DisplayHalfByte(0x10, PulseTen);
    DisplayHalfByte(0x10, PulseSingle);

    j = ii % 10;
    DisplayHalfByte(j, PulseSingle);

    j = (ii / 10) % 10;
    if ((j > 0) || (ii > 99) || IsCalibrate)
    {
        DisplayHalfByte(j, PulseTen);
    }
    j = ii / 100;
    if (j == 1)
    {
        PULBAIIconOn;
    }
    else
    {
        PULBAIIconOff;
    }
}
//******************************************************************************
// DisplayToSYSDIA
//******************************************************************************
void DisplayToSYSDIA(unsigned int SYS, unsigned char position)
{
    if (position == 1)
    {
        if (SYS < 100)
            DisplayHalfByte(0x10, SYSHundred); // 显示空
        else
            DisplayHalfByte(SYS / 100, SYSHundred);

        if (SYS < 10 && mmHgkPaFlag)
        {
            DisplayHalfByte(0x10, SYSTen);
        } // 显示空
        else
            DisplayHalfByte((SYS / 10) % 10, SYSTen);

        DisplayHalfByte(((SYS % 100) % 10), SYSSingle);
    }
    if (position == 2)
    {
        if (SYS < 100)
            DisplayHalfByte(0x10, DIAHundred); // 显示空
        else
            DisplayHalfByte(SYS / 100, DIAHundred);

        if (SYS < 10 && mmHgkPaFlag)
        {
            DisplayHalfByte(0x10, DIATen);
        } // 显示空
        else
            DisplayHalfByte((SYS / 10) % 10, DIATen);

        DisplayHalfByte(((SYS % 100) % 10), DIASingle);
    }
}
//******************************************************************************
// DisplayToMemorySet
//******************************************************************************
void DisplayToMemorySet(unsigned int i)
{

    if (LCD80Y)
    {
        if (i < 100)
            DisplayHalfByte(0X10, MemorySetHundred);
        else
            DisplayHalfByte(i / 100, MemorySetHundred);
    }
    if (i < 10)
        DisplayHalfByte(0x10, MemorySetTen); // 显示空
    else
        DisplayHalfByte((i % 100) / 10, MemorySetTen);
    DisplayHalfByte(i % 10, MemorySetSingle);
    MemoryIconOn; // MR icon display
}
//******************************************************************************
// DisplayLongSD
//******************************************************************************
void DisplayLongData1(unsigned int i)
{
    DisplayHalfByte(i / 10000, MonthSingle);
    DisplayHalfByte((i % 10000) / 1000, DayTen);
    DisplayHalfByte((i % 1000) / 100, DaySingle);
    DisplayHalfByte((i % 100) / 10, HourSingle);
    DisplayHalfByte(i % 10, MINTen);
}
//******************************************************************************
// DisplayLongDT
//******************************************************************************
void DisplayLongData(unsigned int i)
{
    DisplayHalfByte(i / 10000, SYSTen);
    DisplayHalfByte((i % 10000) / 1000, SYSSingle);
    DisplayHalfByte((i % 1000) / 100, DIAHundred);
    DisplayHalfByte((i % 100) / 10, DIATen);
    DisplayHalfByte(i % 10, DIASingle);
}
//******************************************************************************
// darkwordtolcdmin
//******************************************************************************
void darkwordtolcdmin(void)
{
    DisplayHalfByte(0x10, MINSingle);
    DisplayHalfByte(0x10, MINTen);
}
//******************************************************************************
// darkwordtolcdhour
//******************************************************************************
void darkwordtolcdhour(void)
{
    DarkHourTen1;
    DarkHourTen2;
    DisplayHalfByte(0x10, HourSingle);
}
//******************************************************************************
// darkwordtolcdday
//******************************************************************************
void darkwordtolcdday(void)
{
    DisplayHalfByte(0x10, DaySingle);
    DisplayHalfByte(0x10, DayTen);
}
//******************************************************************************
// darkwordtolcdmonth
//******************************************************************************
void darkwordtolcdmonth(void)
{
    MonthTenIconOff;
    DisplayHalfByte(0x10, MonthSingle);
}
//******************************************************************************
// show minute
//******************************************************************************
void showminute(void)
{
    DisplayHalfByte(Minute % 10, MINSingle);
    DisplayHalfByte(Minute / 10, MINTen);
}
//******************************************************************************
// show hour
//******************************************************************************
void showhour(void)
{
    unsigned char D;
    D = Hour;
    if (AMPMLCD)
    {
        if (D > 11)
        {
            D -= 12;
        }
        if (D == 0)
            D = 12;
    }
    DarkHourTen1;
    DarkHourTen2;
    DisplayHalfByte(D % 10, HourSingle);
    if (D > 19)
    {
        DisplayHour20;
    }
    else
    {
        if (D > 9)
        {
            DisplayHourTen1;
            DisplayHourTen2;
        }
        else
        {
            DarkHourTen1;
            DarkHourTen2;
        }
    }
    //	TimePointIconOn;
    if (AMPMLCD && (Hour > 11))
    {
        PMIconOn;
        AMIconOff;
    } // PM;
    if (AMPMLCD && (Hour < 12))
    {
        AMIconOn;
        PMIconOff;
    } // AM;
}
//******************************************************************************
// show day
//******************************************************************************
void showday(void)
{
    DisplayHalfByte(Day % 10, DaySingle);
    DisplayHalfByte(Day / 10, DayTen);
    DayIconOn;
}
//******************************************************************************
// show month
//******************************************************************************
void showmonth(void)
{
    DisplayHalfByte(Month % 10, MonthSingle);
    if (Month > 9)
    {
        MonthTenIconOn;
    }
    else
    {
        MonthTenIconOff;
    }
    MonthIconOn; // display month M
}
//******************************************************************************
// show time
//******************************************************************************
void showtime(void)
{
    if (!NoTimer)
    {
        showhour();
        showminute();
    }
}
//******************************************************************************
// show date
//******************************************************************************
void showdate(void)
{
    showday();
    showmonth();
}
//******************************************************************************
// show year
//******************************************************************************
void showyear(void)
{
    DisplayYear20;                  // 2
    DisplayHalfByte(0, HourSingle); // 20-Year
    DisplayHalfByte(Year.b % 10, MINSingle);
    DisplayHalfByte(Year.b / 10, MINTen);
}

//******************************************************************************
// flash minute
//******************************************************************************
void flashminute(void)
{
    if (T250ms == 0)
    {
        if (OneShot == 1)
        {
            showminute(); // if 1/4 second to show minute process
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1;        // set on shot flag = 1
            darkwordtolcdmin(); // dark minute digit on LCD
        }
    }
}

//******************************************************************************
// flash minute
//******************************************************************************
void flashtimepoint(void)
{
    if (fRTC_500ms == 1)
	{
        TimePointIconOn;
	}
    else
	{
        TimePointIconOff;
	}
}
//******************************************************************************
// flash hour
//******************************************************************************
void flashuser(void)
{

    if (T250ms == 0)
    {
        if (OneShot == 1) // if one shot flag = 0 then
        {
            UserABDisplay();
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1; // set on shot flag = 1
            UserAIconOff;
            UserBIconOff;
        }
    }
}

void flashmemoryset(unsigned char i)
{
    if (T250ms == 0)
    {
        if (OneShot == 1) // if one shot flag = 0 then
        {
            DisplayToMemorySet(i);
            DisplayHalfByte(0xC, DIAHundred);
            DisplayHalfByte(0x13, DIATen);
            DisplayHalfByte(0xb, DIASingle);
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1; // set on shot flag = 1
            MemoryIconOff;
            DisplayHalfByte(0x10, MemorySetTen);
            DisplayHalfByte(0x10, MemorySetSingle);
            if (KeyNumber == 12)
            {
                DisplayHalfByte(0x10, DIAHundred);
                DisplayHalfByte(0x10, DIATen);
                DisplayHalfByte(0x10, DIASingle);
            }
        }
    }
}
void flashhour(void)
{
    if (T250ms == 0)
    {
        if (OneShot == 1) // if one shot flag = 0 then
        {
            showhour(); // if 1/4 second to show hour process
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1;         // set on shot flag = 1
            darkwordtolcdhour(); // dark hour digit on LCD
            if (KeyNumber == 11 || KeyNumber == 12)
            {
                AMIconOff;
                PMIconOff;
            }
        }
    }
    TimePointIconOn;
    if (KeyNumber != 11 && KeyNumber != 12)
    {
        if (AMPMLCD && (Hour > 11))
        {
            PMIconOn;
            AMIconOff;
        } // PM;
        if (AMPMLCD && (Hour < 12))
        {
            AMIconOn;
            PMIconOff;
        } // AM;
    }
}

//******************************************************************************
// flash day
//******************************************************************************
void flashday(void)
{
    if (T250ms == 0)
    {
        if (OneShot == 1)
        {
            OneShot = 0;
            showday();
        }
    }
    else
    {
        if (OneShot == 0)
        {
            OneShot = 1;
            darkwordtolcdday();
        }
    }
    DayIconOn;
}

//******************************************************************************
// flash month
//******************************************************************************
void flashmonth(void)
{

    if (T250ms == 0)
    {
        if (OneShot == 1) // if one shot flag = 0 then
        {
            showmonth(); // if 1/4 second to show month process
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1;          // set on shot flag = 1
            darkwordtolcdmonth(); // dark hour digit on LCD
        }
    }
    MonthIconOn;
    DayIconOn;
}
//******************************************************************************
// flash year
//******************************************************************************
void flashyear(void)
{
    if (T250ms == 0)
    {
        if (OneShot == 1)
        {
            OneShot = 0;
            showyear();
        }
    }
    else
    {
        if (OneShot == 0)
        {
            OneShot = 1;
            // DarkAllIcon();
            darkwordtolcdhour();
            darkwordtolcdmin();
        }
    }
}

//************************************************/
void flashParameter(void)
{
    if (T250ms == 0)
    {
        if (OneShot == 1)
        {
            DisplayToSYSDIA(BB, 2);
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0)
        {
            OneShot = 1;
            DisplayHalfByte(0x10, DIASingle);
            DisplayHalfByte(0x10, DIATen);
            DisplayHalfByte(0x10, DIAHundred);
        }
    }
}

void UserABDisplay(void)
{
    if (TwoUser == 1)
    {
        if (UserA == 1)
        {
            UserAIconOn;
            UserBIconOff;
        }
        else
        {
            UserBIconOn;
            UserAIconOff;
        }
    }
    else
    {
        UserAIconOff;
        UserBIconOff;
    }
}

void ShowVoice(void)
{
    if (KeyNumber == 7 && VoiceSetEnable)
    {
        if (VoiceEnable)
            VoiceOffIconOff;
        else
            VoiceOffIconOn;
    }
}

void showpressure(void)
{
    if (T125ms == 0)
        OneShotDC = 0;
    else
    {
        if (OneShotDC == 0)
        {
            OneShotDC = 1;
            showpres();
            CheckBatteryCOM();
        }
    }
}

void mmHgKpaDisplay(unsigned char SysDisplay, unsigned char DiaDisplay)
{
    unsigned int TempSYS;
    unsigned int TempDIA;
    if (KeyNumber != 7 && !LCDType2 && !BTIconEnable)
        ResultIcon3On;
    if (mmHgkPaFlag == 1)
    {
        DisplayToSYSDIA(SysDisplay, 1); // mmHg
        DisplayToSYSDIA(DiaDisplay, 2);
        if (UnitSetEnable || UnitIcon)
            mmHgIconOn;     // mmHg
        kPaIconOff;         // 去掉kpa
        kPaPointDIAIconOff; // 去掉点
        kPaPointSYSIconOff; // 去掉点
    }
    else
    {
        TempSYS = SysDisplay;
        TempDIA = DiaDisplay;
        TempSYS *= 4;
        TempSYS /= 3;
        TempDIA *= 4;
        TempDIA /= 3;

        DisplayToSYSDIA(TempSYS, 1); // 20101211新增Kpa显示
        DisplayToSYSDIA(TempDIA, 2);
        mmHgIconOff;       // 去掉mmHg
        kPaIconOn;         // kpa
        kPaPointSYSIconOn; // 点
        kPaPointDIAIconOn;
    }
}

void showpres(void)
{
    unsigned int TempPressure;
    TempPressure = PressuremmHgw;
    if (BPTestFlag)
    {
        if (TempPressure >= 300)
            TempPressure = 299;
    }
    if (mmHgkPaFlag == 1)
    {
        DisplayToSYSDIA(TempPressure, 2);
        if (UnitSetEnable || UnitIcon)
        {
            if (!LCD80Y)
                mmHgIconOn;
        }
    }
    else
    {
        TempPressure *= 4;
        TempPressure /= 3;
        DisplayToSYSDIA(TempPressure, 2);
        if (!LCD80Y)
            kPaIconOn; // kpa
        kPaPointDIAIconOn;
    }
    UserABDisplay();
    ShowVoice();
    if (KeyNumber == 7)
        ShowPumpWHO();
}

void ShowPumpWHO(void)
{
    if (PressuremmHgw >= 165)
        BAR1IconOn;
    else
        BAR1IconOff;
    if (PressuremmHgw >= 150)
        BAR2IconOn;
    else
        BAR2IconOff;
    if (PressuremmHgw >= 135)
        BAR3IconOn;
    else
        BAR3IconOff;
    if (PressuremmHgw >= 115)
        BAR4IconOn;
    else
        BAR4IconOff;
    if (PressuremmHgw >= 100)
        BAR5IconOn;
    else
        BAR5IconOff;
    if (PressuremmHgw >= 85)
        BAR6IconOn;
    else
        BAR6IconOff;
    if (PressuremmHgw >= 70)
        BAR7IconOn;
    else
        BAR7IconOff;
    BAR8IconOn;
}

void Calshowpres(void)
{
    unsigned char temp;
    temp = PressuremmHgw % 10;
    DisplayToSYSDIA(PressuremmHgw / 10, 2);
    DisplayHalfByte(temp, PulseSingle);
    if (PressuremmHgw / 10 > 399)
    {
        DisplayToSYSDIA(399, 2);
    }
}

void ShowBTBar(void)
{
    switch (ShowBTLevel)
    {
    case 1:
        WHOLevelIconOff;
        WHOLevel1Icon;
        return;
    case 2:
        WHOLevelIconOff;
        WHOLevel2Icon;
        return;
    case 3:
        WHOLevelIconOff;
        WHOLevel3Icon;
        return;
    case 4:
        WHOLevelIconOff;
        WHOLevel4Icon;
        return;
    case 5:
        WHOLevelIconOff;
        WHOLevel4Icon;
        WHOLevel5Icon;
        return;
    case 6:
        WHOLevelIconOff;
        WHOLevel4Icon;
        WHOLevel6Icon;
        return;
    }
}

void heartsignon(void)
{
    HeartIconOn;
}

void heartsignoff(void)
{
    HeartIconOff;
}

void mmHgKpaSetDisplay(void)
{
    if (mmHgkPaFlag == 1)
    {
        DisplayHalfByte(0, SYSSingle);
        DisplayHalfByte(0, DIASingle);
        DisplayHalfByte(0x10, SYSTen);
        DisplayHalfByte(0x10, DIATen);
        if (UnitSetEnable || UnitIcon)
            mmHgIconOn;     // mmHg
        kPaIconOff;         // 去掉kpa
        kPaPointDIAIconOff; // 去掉点
        kPaPointSYSIconOff; // 去掉点
    }
    else
    {
        DisplayHalfByte(0, SYSTen);
        DisplayHalfByte(0, DIATen);
        DisplayHalfByte(0, SYSSingle);
        DisplayHalfByte(0, DIASingle);
        mmHgIconOff;       // kpa
        kPaIconOn;         // 去掉mmHg
        kPaPointSYSIconOn; // 点
        kPaPointDIAIconOn;
    }
}

void showerror(void)
{
    unsigned char i;
    BPTestFlag = 0;
    AutoOffTimew = 0x0000;
    AutoTestFlag = 0;
    DarkAllIcon();

    OutRedOn;    // OutRed=1;
    OutGreenOff; // OutGreen=0;
    if (BPLevelType == 5)
        LedOff;
    // if(ConnectFlag&&BTIconEnable) BTIconOn;
    BB = VALVEOFF | PUMPOFF;
    iocontroloff();

    DisplayHalfByte(0xe, DIAHundred);       /* 'E' */
    DisplayHalfByte(0x17, DIATen);          /* '-' */
    DisplayHalfByte(ResultCode, DIASingle); // 错误代码
    for (i = 0; i < 5; i++)
    {              /* show Err to left digit on LCD */
        BUZZER_EN; /* buzzer 3/4 second beep then delay 3/8 second */
        delay(8);
        BUZZER_DIS;
        delay(8);
    }
    SendMemoryFlag = 0;
    BTFlag = 0;
    if (UartType == 1 || UartType == 4 || UartType == 5 || UartType == 6)
    {
        Send_ErrorCode();
        RXIEnable;
        BTFlag = 0;
    }

    if ((VoiceEnable == 1) && ((ResultCode == 1) || (ResultCode == 2) || (ResultCode == 3) || (ResultCode == 5)))
    {
        if (VoiceType == 1 || VoiceType == 10 || VoiceType == 12 || VoiceType == 14)
        {
            if (VoiceType==1 && VoiceType2 == 4)//BP507内置语音
            {
                inner_voice_one_cmd(INNER_CMD_ERROR_DETECTED_DURING_MEASUREMENT_PLEASE_REST_TWO_MINUTES_BEFORE_REMEASURING);
            }
            else
            {
                SoundCommand(0xE6);
            }
        }
        else if (VoiceType >= 2 && VoiceType <= 4)
            SoundCommand2(0x8E);
        else if (VoiceType == 5)
            SoundAllCommand(0x22, 0, 0, 0);
        else if (VoiceType == 7)
            SoundCommand(0xBE);
        else if (VoiceType == 6)
            SoundCommand2(0xE6);
        else if (VoiceType == 8 && VoiceFlag < 5)
        {
            SoundFive();
            SoundCommand2(0xCE);
        }
        else if (VoiceType == 9)
            SoundCommand(0xCF);
        else if (VoiceType == 11)
            SoundCommand2(0xCF);
        else if (VoiceType == 13 && VoiceLevel > 0)
        {
            SoundThree();
            SoundCommand2(0xE3);
        }
        else if (VoiceType == 15)
        {
            new_cn_ic_voice_send_cmd_server(VOICE_CMD_ERROR_DETECTED);
        } // 测量时侦测到错误,请休息兩分钟后,再重新量测
    }     // 测量时侦测到错误,请休息兩分钟后,再重新量测

    AutoOffTimew = 0x0000;

    N = 0;
    KeyIn = 1;
    KeyModeFlag.b = 0;
    do
    {
        delay(1);
        if (UartType == 5 && WorkMode == 1)
            break;
        if (AutoOffTimew > AUTOOFFTIME && !AllTimeFlag)
            break;

        if (KeyNumber == 11)
        {
            if (!KEY_MEMORYUP || !KEY_MEMORYDOWN)
            {
                MemoryKeyFlag = 1;
                break;
            }
            if (LongSetFlag)
            {
                SetKeyFlag = 1;
                break;
            }
        }
        if (KeyNumber == 12)
        {
            if (!KEY_TIME)
            {
                MemoryKeyFlag = 1;
                break;
            }
        }

    } while (IsPowerOn && KEY_POWER && !BTFlag && !SendMemoryFlag);

    IsShowPressure = 0; /* set show pressure flag = 0 */
    IsAlgorithm = 0;    /* set algorithm flag = 0 */
    IsAlgoEnd = 0;      /* set algorithm enf flag = 0 */

    DarkAllIcon(); /* dark all pattern on LCD */
                   //	showtime();

    IsPowerOn = 0;
    // showtime();
    // ShowAVG = 1;
}

void ShowWHO(unsigned char WHOSYS, unsigned char WHODIA)
{
    if (LCD80Y)
    {
        ResultIcon2On;
    }
    if (VoiceType == 10)
    {
        SLevel = 0;
        if (WHOSYS < 90 && WHODIA < 50)
        {
            SLevel = 1;
        }
        if (WHOSYS >= 90 && WHOSYS < 140 && WHODIA < 50)
        {
            SLevel = 2;
        }
        if (WHOSYS >= 140 && WHODIA < 50)
        {
            SLevel = 3;
        }
        if (WHOSYS < 90 && WHODIA >= 50 && WHODIA < 90)
        {
            SLevel = 4;
        }
    }

    if (KeyNumber == 7)
    {
        if (WHOSYS > 165)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOn;
            BAR4IconOn;
            BAR3IconOn;
            BAR2IconOn;
            BAR1IconOn;
        }
        else if (WHOSYS > 150)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOn;
            BAR4IconOn;
            BAR3IconOn;
            BAR2IconOn;
            BAR1IconOff;
        }
        else if (WHOSYS > 135)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOn;
            BAR4IconOn;
            BAR3IconOn;
            BAR2IconOff;
            BAR1IconOff;
        }
        else if (WHOSYS > 115)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOn;
            BAR4IconOn;
            BAR3IconOff;
            BAR2IconOff;
            BAR1IconOff;
        }
        else if (WHOSYS > 100)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOn;
            BAR4IconOff;
            BAR3IconOff;
            BAR2IconOff;
            BAR1IconOff;
        }
        else if (WHOSYS > 85)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOn;
            BAR5IconOff;
            BAR4IconOff;
            BAR3IconOff;
            BAR2IconOff;
            BAR1IconOff;
        }
        else if (WHOSYS > 70)
        {
            BAR8IconOn;
            BAR7IconOn;
            BAR6IconOff;
            BAR5IconOff;
            BAR4IconOff;
            BAR3IconOff;
            BAR2IconOff;
            BAR1IconOff;
        }
        else
        {
            BAR8IconOn;
            BAR7IconOff;
            BAR6IconOff;
            BAR5IconOff;
            BAR4IconOff;
            BAR3IconOff;
            BAR2IconOff;
            BAR1IconOff;
        }

        if (WHODIA > 165)
        {
            BAR2IconOff;
            BAR3IconOff;
            BAR4IconOff;
            BAR5IconOff;
            BAR6IconOff;
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 150)
        {
            BAR3IconOff;
            BAR4IconOff;
            BAR5IconOff;
            BAR6IconOff;
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 135)
        {
            BAR4IconOff;
            BAR5IconOff;
            BAR6IconOff;
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 115)
        {
            BAR5IconOff;
            BAR6IconOff;
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 100)
        {
            BAR6IconOff;
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 85)
        {
            BAR7IconOff;
            BAR8IconOff;
        }
        else if (WHODIA > 70)
        {
            BAR8IconOff;
        }
    }
    if (BPLevelType == 0)
        return; // 无显示WHO符号
    if (BPLevelType == 2)
        goto BPLevelTypeis5; // 2表示5格； 否则6格
    if (BPLevelType == 4)
    {
        goto Type4;
    }
    //*************************************************6 格
    if ((WHOSYS >= WHOSYS5) || (WHODIA >= WHODIA5))
    {
        if (KeyNumber != 7)
        {
            WHOLevel6Icon;
            WHOLevel5Icon;
        }
        if (KeyNumber != 7)
        {
            WHOLevel4Icon;
            WHOLevel3Icon;
            WHOLevel2Icon;
            WHOLevel1Icon;
        }
        if (VoiceType == 1 || VoiceType == 6 || VoiceType == 7 || VoiceType == 14)
            WHOLevel = 5;
        else if ((VoiceType >= 2 && VoiceType <= 5) || VoiceType == 8 || VoiceType == 11)
            WHOLevel = 6;
        else if (VoiceType == 9)
            WHOLevel = 3;
        else if (VoiceType == 13 && VoiceFlag > 0)
            WHOLevel = 3;
        else
            WHOLevel = 5;

        if (BPLevelType == 5)
        {
            LedOff;
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOff; // OutGreen=0;
                OutRedOn;    // OutRed=1;
            }
        }
        return;
    }
    if ((WHOSYS >= WHOSYS4) || (WHODIA >= WHODIA4))
    {
        if (KeyNumber != 7)
            WHOLevel5Icon;
        if (KeyNumber != 7)
        {
            WHOLevel4Icon;
            WHOLevel3Icon;
            WHOLevel2Icon;
            WHOLevel1Icon;
        }
        if (VoiceType == 1 || VoiceType == 6 || VoiceType == 7 || VoiceType == 14)
            WHOLevel = 4;
        else if ((VoiceType >= 2 && VoiceType <= 5) || VoiceType == 8 || VoiceType == 11)
            WHOLevel = 5;
        else if (VoiceType == 9)
            WHOLevel = 4;
        else
            WHOLevel = 4;

        if (BPLevelType == 5)
        {
            LedOff;
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOff; // OutGreen=0;
                OutRedOn;    // OutRed=1;
            }
        }
        return;
    }
    if ((WHOSYS >= WHOSYS3) || (WHODIA >= WHODIA3))
    {
        if (KeyNumber != 7)
        {
            WHOLevel4Icon;
            WHOLevel3Icon;
            WHOLevel2Icon;
            WHOLevel1Icon;
        }
        if (VoiceType == 1 || VoiceType == 6 || VoiceType == 7 || VoiceType == 14)
            WHOLevel = 3;
        else if ((VoiceType >= 2 && VoiceType <= 5) || VoiceType == 8 || VoiceType == 11)
            WHOLevel = 4;
        else if (VoiceType == 9)
            WHOLevel = 4;
        else if (VoiceType == 13 && VoiceFlag > 0)
            WHOLevel = 2;
        else
            WHOLevel = 3;

        if (BPLevelType == 5)
        {
            LedOff;
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOff; // OutGreen=0;
                OutRedOn;    // OutRed=1;
            }
        }
        return;
    }
    if ((WHOSYS >= WHOSYS2) || (WHODIA >= WHODIA2))
    {
        if (KeyNumber != 7)
        {
            WHOLevel3Icon;
            WHOLevel2Icon;
            WHOLevel1Icon;
        }
        if (VoiceType == 1 || VoiceType == 6 || VoiceType == 7 || VoiceType == 14)
            WHOLevel = 2;
        else if ((VoiceType >= 2 && VoiceType <= 5) || VoiceType == 8 || VoiceType == 11)
            WHOLevel = 3;
        else if (VoiceType == 9)
            WHOLevel = 2;
        else
            WHOLevel = 2;

        if (BPLevelType == 5)
        {
            LedOff;
            OutGreenOn; // OutGreen=1;
            OutRedOff;  // OutRed=0;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOn; // OutGreen=1;
                OutRedOn;   // OutRed=1;
            }
        }
        return;
    }
    if ((WHOSYS >= WHOSYS1) || (WHODIA >= WHODIA1))
    {
        if (KeyNumber != 7)
        {
            WHOLevel2Icon;
            WHOLevel1Icon;
        }
        if (VoiceType == 1 || VoiceType == 6 || VoiceType == 7 || VoiceType == 14)
            WHOLevel = 1;
        else if ((VoiceType >= 2 && VoiceType <= 5) || VoiceType == 8 || VoiceType == 11)
            WHOLevel = 2;
        else if (VoiceType == 9)
            WHOLevel = 1;
        else
            WHOLevel = 1;
        if (BPLevelType == 5)
        {
            LedOn;
            OutGreenOff; // OutGreen=0;
            OutRedOff;   // OutRed=0;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOn; // OutGreen=1;
                OutRedOff;  // OutRed=0;
            }
        }
        return;
    }
    if ((WHOSYS < WHOSYS1) && (WHODIA < WHODIA1))
    {
        if (KeyNumber != 7)
            WHOLevel1Icon;
        WHOLevel = 1;
        if (BPLevelType == 5)
        {
            LedOn;
            OutGreenOff; // OutGreen=0;
            OutRedOff;   // OutRed=0;
        }
        else
        {
            if (BLFlag || KeyNumber == 7)
            {
                OutGreenOn; // OutGreen=1;
                OutRedOff;  // OutRed=0;
            }
        }
        if (WHOSYS < 80 && WHODIA < 50)
        {
            if (VoiceType == 13 && VoiceFlag > 0)
                WHOLevel = 5;
        }
        return;
    }
BPLevelTypeis5:
    //*************************************************5 格
    if ((WHOSYS > 145) || (WHODIA > 95))
    {
        WHOLevel = 5;
        if (KeyNumber != 7)
            WHOLevel5Icon;
        if (KeyNumber != 7)
            WHOLevel4Icon;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        return;
    }
    if ((WHOSYS >= 135) || (WHODIA >= 85))
    {
        WHOLevel = 4;
        if (KeyNumber != 7)
            WHOLevel4Icon;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        return;
    }
    if ((WHOSYS >= 121) || (WHODIA >= 81))
    {
        WHOLevel = 3;
        if (KeyNumber != 7)
            WHOLevel3Icon;
        if (BLFlag)
        {
            OutGreenOn; // OutGreen=1;
            OutRedOn;   // OutRed=1;
        }
        return;
    }
    if ((WHOSYS >= 110) || (WHODIA >= 70))
    {
        WHOLevel = 2;
        if (KeyNumber != 7)
            WHOLevel2Icon;
        if (BLFlag)
        {
            OutGreenOn; // OutGreen=1;
            OutRedOff;  // OutRed=0;
        }
        return;
    }
    if ((WHOSYS < 110) && (WHODIA < 70))
    {
        WHOLevel = 1;
        if (KeyNumber != 7)
            WHOLevel1Icon;
        if (BLFlag)
        {
            OutGreenOn; // OutGreen=1;
            OutRedOff;  // OutRed=0;
        }
        return;
    }
Type4:
    if ((WHOSYS >= WHOSYS5) || (WHODIA >= WHODIA5))
    {
        WHOLevel = 6;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        WHOLevel6Icon;
        WHOLevel5Icon;
        WHOLevel4Icon;
        WHOLevel3Icon;
        WHOLevel2Icon;
        WHOLevel1Icon;
        return;
    }
    if ((WHOSYS >= WHOSYS4) || (WHODIA >= WHODIA4))
    {
        WHOLevel = 5;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        WHOLevel5Icon;
        WHOLevel4Icon;
        WHOLevel3Icon;
        WHOLevel2Icon;
        WHOLevel1Icon;
        return;
    }
    if ((WHOSYS >= WHOSYS3) || (WHODIA >= WHODIA3))
    {
        WHOLevel = 4;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        WHOLevel4Icon;
        WHOLevel3Icon;
        WHOLevel2Icon;
        WHOLevel1Icon;
        return;
    }
    if ((WHOSYS >= WHOSYS2) || (WHODIA >= WHODIA1))
    {
        WHOLevel = 3;
        if (BLFlag)
        {
            OutGreenOff; // OutGreen=0;
            OutRedOn;    // OutRed=1;
        }
        WHOLevel3Icon;
        WHOLevel2Icon;
        WHOLevel1Icon;
        return;
    }
    if ((WHOSYS >= WHOSYS1) && (WHODIA < WHODIA1))
    {
        WHOLevel = 2;
        if (BLFlag)
        {
            OutGreenOn; // OutGreen=1;
            OutRedOn;   // OutRed=1;
        }
        WHOLevel2Icon;
        WHOLevel1Icon;
        return;
    }
    if ((WHOSYS < WHOSYS1) && (WHODIA < WHODIA1))
    {
        WHOLevel = 1;
        if (BLFlag)
        {
            OutGreenOn; // OutGreen=1;
            OutRedOff;  // OutRed=0;
        }
        WHOLevel1Icon;
        return;
    }
}

void EngTurDisplay(void) // 英土显示
{
    if (VoiceType == 4)
    {
        if (VoiceFlag == 1)
        {
            mmHgIconOn;
            kPaIconOff;
        }
        else
        {
            kPaIconOn;
            mmHgIconOff;
        }
    }
    else
    {
        SPDisplay();
    }
}

void SPDisplay(void) // 普通话粤语设置
{
    DisplayHalfByte(0x5, SYSHundred);
    DisplayHalfByte(0x1b, SYSTen);
    if (VoiceFlag == 1)
    {
        DisplayHalfByte(1, DIASingle);
    }
    else
    {
        DisplayHalfByte(2, DIASingle);
    }
}

void ShowVoiceCET(void)
{
    if (VoiceFlag == 0)
    {
        DisplayHalfByte(0xC, DIAHundred);
        DisplayHalfByte(0x11, DIATen);
        DisplayHalfByte(0x1C, DIASingle); // 中
    }
    if (VoiceFlag == 1)
    {
        DisplayHalfByte(0xE, DIAHundred);
        DisplayHalfByte(0x1C, DIATen);
        DisplayHalfByte(0x9, DIASingle); // 英
    }
    if (VoiceFlag == 2)
    {
        DisplayHalfByte(0x1A, DIAHundred);
        DisplayHalfByte(0x11, DIATen);
        DisplayHalfByte(0x1, DIASingle); // 泰语
    }
}

void ShowVoiceLevel(void)
{
    if (VoiceLevel > 0)
    {
        DisplayHalfByte(0x17, DIAHundred);
        DisplayHalfByte(VoiceLevel, DIATen);
        DisplayHalfByte(0x17, DIASingle);
    }
    else
    {
        DisplayHalfByte(0x0, DIAHundred);
        DisplayHalfByte(0xf, DIATen);
        DisplayHalfByte(0xf, DIASingle);
    }
}

void showalarm(void)
{
    uint8 D;
    DisplayHalfByte(AlarmMinute[AlarmN] % 10, MINSingle);
    DisplayHalfByte(AlarmMinute[AlarmN] / 10, MINTen);
    if (AMPMLCD && (AlarmHour[AlarmN] > 11))
    {
        PMIconOn;
        AMIconOff;
    } // PM;
    if (AMPMLCD && (AlarmHour[AlarmN] < 12))
    {
        AMIconOn;
        PMIconOff;
    } // AM;
    D = AlarmHour[AlarmN];
    if (AMPMLCD)
    {
        if (D > 11)
        {
            D -= 12;
        }
        if (D == 0)
            D = 12;
    }
    DisplayHalfByte(D % 10, HourSingle);
    DarkHourTen1;
    DarkHourTen2;
    if (D > 19)
    {
        DisplayHour20;
    }
    else
    {
        if (D > 9)
        {
            DisplayHourTen1;
            DisplayHourTen2;
        }
        else
        {
            DarkHourTen1;
            DarkHourTen2;
        }
    }
    TimePointIconOn;

    if (AlarmOnOff[AlarmN] == 0)
    {
        DisplayHalfByte(0x0, DIAHundred);
        DisplayHalfByte(0xF, DIATen);
        DisplayHalfByte(0xF, DIASingle);
    }
    else
    {
        DisplayHalfByte(0x10, DIAHundred);
        DisplayHalfByte(0x0, DIATen);
        DisplayHalfByte(0x1c, DIASingle);
    }

    DisplayHalfByte(0xA, SYSHundred);
    DisplayHalfByte(0x13, SYSTen);
    DisplayHalfByte(AlarmN + 1, SYSSingle);
}

void flashalarm(unsigned char i)
{
    if (T250ms == 0)
    {
        if (OneShot == 1)
        {
            showalarm(); // if 1/4 second to show minute process
            OneShot = 0;
        }
    }
    else
    {
        if (OneShot == 0) // if one shot flag = 0 then
        {
            OneShot = 1; // set on shot flag = 1
            if (i == 0)
                darkwordtolcdhour();
            else if (i == 1)
                darkwordtolcdmin();
            else if (i == 2)
            {
                DisplayHalfByte(0x10, DIAHundred);
                DisplayHalfByte(0x10, DIATen);
                DisplayHalfByte(0x10, DIASingle);
            }
        }
    }
}

void SpeakDisplay(void)
{
    DarkAllIcon();
    if (KeyNumber == 7)
    {
        VoiceOffIconOn;
        if (VoiceEnable == 1)
        {
            DisplayHalfByte(0x00, DIAHundred);
            DisplayHalfByte(0x1c, DIATen);
        }
        else
        {
            DisplayHalfByte(0x00, DIAHundred);
            DisplayHalfByte(0x0f, DIATen);
            DisplayHalfByte(0x0f, DIASingle);
        }
    }
    else
    {
        // DisplayHalfByte(0x05,SYSHundred);
        DisplayHalfByte(0x05, SYSTen);
        DisplayHalfByte(0x1b, SYSSingle);

        if (VoiceEnable == 1)
        {
            DisplayHalfByte(0x00, DIATen);
            DisplayHalfByte(0x1c, DIASingle);
        }
        else
        {
            DisplayHalfByte(0x10, DIAHundred);
            DisplayHalfByte(0x00, DIATen);
            DisplayHalfByte(0x0f, DIASingle);
        }
    }
}

void flashCL(void)
{
    DarkAllIcon();
    N = 0;
    DisplayHalfByte(0x0c, DIATen);    // 'C'
    DisplayHalfByte(0x13, DIASingle); // 'L'
    MemoryIconOn;                     // MarkMEMORY = 1;
    BUZZER_EN;
    delay(32);
    do
    {
        BUZZER_DIS;
        DisplayHalfByte(0x10, DIATen);    // 'NULL'
        DisplayHalfByte(0x10, DIASingle); // 'NULL'
        delay(8);
        DisplayHalfByte(0x0c, DIATen);    // 'C'
        DisplayHalfByte(0x13, DIASingle); // 'L'
        BUZZER_EN;
        delay(8);
        BUZZER_DIS;
        N++;
    } while (N < 4);
    do
    {
    } while (KEY_MEMORYDOWN == 0);
    do
    {
    } while (KEY_MEMORYUP == 0);
    keydelay();
    DarkAllIcon();
}

void ShowRestTime(uint32 TimeCount)
{
    uint32 temp;
    temp = TimeCount / 60;
    TimeCount %= 60;
    DarkHourTen1;
    DarkHourTen2;
    DisplayHalfByte(temp % 10, HourSingle);
    if (temp > 19)
    {
        DisplayHour20;
    }
    else if (temp > 9)
    {
        DisplayHourTen1;
        DisplayHourTen2;
    }
    DisplayHalfByte(TimeCount / 10, MINTen);
    DisplayHalfByte(TimeCount % 10, MINSingle);
    TimePointIconOn;
}

void ShowMemoryDate(unsigned char MM, unsigned char DD)
{

    DisplayHalfByte(MM % 10, MonthSingle);
    DisplayHalfByte(DD % 10, DaySingle);
    DisplayHalfByte(DD / 10, DayTen);
    if (MM > 9)
    {
        MonthTenIconOn;
    }
    else
    {
        MonthTenIconOff;
    }
    MonthIconOn;
    DayIconOn;
}
/************************************************/
void ShowMemoryTime(unsigned char HH, unsigned char MM)
{
    if (AMPMLCD && (HH > 11))
    {
        PMIconOn;
        AMIconOff;
    } // PM;
    if (AMPMLCD && (HH < 12))
    {
        AMIconOn;
        PMIconOff;
    } // AM;
    if (AMPMLCD)
    {
        if (HH == 0)
        {
            HH = 12;
        } // 20101212新增12小时制时,0点即为12点
        else
        {
            if (HH > 12)
            {
                HH -= 12;
            }
        }
    }
    TimeTenIconOff1;
    TimeTenIconOff2;
    DisplayHalfByte(HH % 10, HourSingle);
    DisplayHalfByte(MM % 10, MINSingle);
    DisplayHalfByte(MM / 10, MINTen);
    TimePointIconOn; // :
    if (HH > 19)
    {
        DisplayHour20;
    } // 2
    else
    {
        if (HH > 9)
        {
            Time1IconOn1;
            Time1IconOn2;
        } // 1
        else
        {
            TimeTenIconOff1;
            TimeTenIconOff2;
        }
    }
}

void lowbsignon(void)
{
    LBTIconOn;
}

void LCDTEST(void)
{
    uint8 i;
    for (i = 0; i < 28; i++)
    {
        DisplayHalfByte(i, 7);
        DisplayHalfByte(i, 13);
        delay(75);
    }

    UserAIconOn;
    nop4();
    UserAIconOff;
    nop4();
    UserAIconOn;
    nop4();
    UserBIconOn;
    nop4();
    UserBIconOff;
    nop4();
    UserBIconOn;
    nop4();
    MonthTenIconOn;
    nop4();
    MonthTenIconOff;
    nop4();
    MonthTenIconOn;
    nop4();
    MonthIconOn;
    nop4();
    MonthIconOff;
    nop4();
    MonthIconOn;
    nop4();
    AMIconOn;
    nop4();
    AMIconOff;
    nop4();
    AMIconOn;
    nop4();
    PMIconOn;
    nop4();
    PMIconOff;
    nop4();
    PMIconOn;
    nop4();
    Time1IconOn1;
    nop4();
    Time1IconOn2;
    nop4();
    Time2IconOn;
    nop4();
    TimeTenIconOff1;
    nop4();
    TimeTenIconOff2;
    nop4();
    TimePointIconOn;
    nop4();
    TimePointIconOff;
    nop4();
    TimePointIconOn;
    nop4();
    kPaPointSYSIconOn;
    nop4();
    kPaPointSYSIconOff;
    nop4();
    kPaPointSYSIconOn;
    nop4();
    kPaPointDIAIconOn;
    nop4();
    kPaPointDIAIconOff;
    nop4();
    kPaPointDIAIconOn;
    nop4();
    MemoryIconOn;
    nop4();
    MemoryIconOff;
    nop4();
    MemoryIconOn;
    nop4();
    /*PADIconOn;
    nop4();
    PADIconOff;
    nop4();
    PADIconOn;
    nop4();
    LBTIconOn;
    nop4();
    LBTIconOff;
    nop4();
    LBTIconOn;
    nop4();
    HeartIconOn;
    nop4();
    HeartIconOff;
    nop4();
    HeartIconOn;
    nop4();
    PULBAIIconOn;
    nop4();
    PULBAIIconOff;
    nop4();
    PULBAIIconOn;
    nop4();*/
    mmHgIconOn;
    nop4();
    mmHgIconOff;
    nop4();
    mmHgIconOn;
    nop4();
    kPaIconOn;
    nop4();
    kPaIconOff;
    nop4();
    kPaIconOn;
    nop4();
    WHOLevel1Icon;
    nop4();
    WHOLevel2Icon;
    nop4();
    WHOLevel3Icon;
    nop4();
    WHOLevel4Icon;
    nop4();
    WHOLevel5Icon;
    nop4();
    WHOLevel6Icon;
    nop4();
    WHOLevelIconOff;
    nop4();
    DisplayYear20;
    nop4();
    DarkHourTen1;
    nop4();
    DarkHourTen2;
    nop4();
    DisplayYear20;
    nop4();
}
